package com.zxg.util.concurrent.multi;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BasicProcessTask<T> implements Runnable {
  private final static Logger log = LoggerFactory.getLogger(BasicProcessTask.class);

  List<T>                     details;

  BasicProcessTaskExecutor<T> executor;

  public BasicProcessTask(List<T> details, BasicProcessTaskExecutor<T> executor) {
    super();
    this.details = details;
    this.executor = executor;
  }

  public List<T> getDetails() {
    return details;
  }

  public void setDetails(List<T> details) {
    this.details = details;
  }

  @Override
  public void run() {
    if (details == null)
      return;

    for (T detail : details) {
      try {
        executor.execTask(detail);
      } catch (Exception e) {
        log.error("BasicProcessTask error:", e);
        continue;
      }
    }

  }

}
